<template>
<div>
  <ul>
    <li v-for="(item,index) in arr " :key="index">
      <span>{{item}}</span>
      <button @click="delFn(index)">删除</button>
    </li>
    <button @click="addFn">添加</button>
  </ul>
</div>
</template>
<script>
export default {
  data(){
    return {
      arr:[1,2,3,4]
    }
  },
  methods: {
    addFn(){
      var math=Math.floor(Math.random()*(100-1))+1;
      this.arr.push(math)
    },
    delFn(index){
      this.arr.splice(index,1);    
    }
  }
};
</script>